//饿汉模式
class singleton{
    private  static  singleton instance=new singleton();

    private singleton() {
    }
    public  static singleton getInstance(){
        return instance;
    }
}
public class ThreadDemo1 {
    public static void main(String[] args) {
        //singleton s=new singleton();//这里为啥报错了？
        singleton s1=singleton.getInstance();
        singleton s2=singleton.getInstance();
        System.out.println(s1==s2);//这个结果是true为啥了
    }

}
